<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="utf-8">
        <title><spring:message code="user_UserManager"/></title>
        <%@ include file="/WEB-INF/views/include/head.jsp"%> 
        <link rel="stylesheet" href="${ctxStatic}/css/list.css">
        <script type="text/javascript">
            function clean(){
                $("input").val("");
                $("#searchForm").submit();
           }
        </script> 
    </head>
    <body>
        <sys:message content="${message}"/>
        <div class="listSearchBox clearfix">
            <form  id="searchForm" action="${ctx}/sys/user/list" method="post">
                <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
                <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
                <div class="searchLeft clearfix">
                    <div class="searchSm clearfix">
                        <!-- 人员姓名 -->
                        <p class="searchTxt"><spring:message code="user_userNames"/></p>
                        <div class="searchInp">
                            <input type="text" id="firstName"  name="firstName" value="${user.firstName}"/>
                        </div>
                    </div>
                    <div class="searchSm clearfix">
                        <!-- 人员角色 -->
                        <p class="searchTxt"><spring:message code="user_role"/></p>
                        <div class="searchInp">
                            <input type="text" id="role.roleName" name="role.roleName" value="${user.role.roleName}">
                        </div>
                    </div>
                </div>
                <div class="searchRight">
                    <c:if test="${shopId!=null&&shopId!=''&&shopId!=-1}">
                    <shiro:hasPermission name="sys:user:edit">
                        <button type="button" class="btn-cj" onclick="popup('935px','550px','${ctx}/sys/user/form')"><spring:message code="common_create"/></button>
                    </shiro:hasPermission> 
                    </c:if>
                    <shiro:hasPermission name="sys:user:view">
                        <button type="button" class="btn-js" onclick="clean()"><spring:message code="common_reset"/></button>
                        <button type="button" class="btn-js"  onclick="return page();"><spring:message code="commom_check"/></button>
                    </shiro:hasPermission>
                </div>
            </form>   
        </div>
        <div class="tableBox">
            <div class="tableBoxScroll">
                <table cellpadding="0">
                    <thead>
                        <tr>
                            <th>No.</th>
                            <!-- 登录ID -->
                            <th><spring:message code="user_loginId"/></th>
                            <!-- 姓氏 -->
                            <th><spring:message code="user_surname"/></th>
                            <!-- 名字 -->
                            <th><spring:message code="user_showName"/></th>
                            <!-- 性别 -->
                            <th><spring:message code="user_sex"/></th>
                            <!-- 人员角色 -->
                            <th><spring:message code="user_role"/></th>
                            <!-- 状态 -->
                            <th><spring:message code="user_state"/></th>
                            <!-- 最后登录日 -->
                            <th><spring:message code="user_lastGoDate"/></th>
                            <!-- 创建人 -->
                            <th><spring:message code="user_creatUser"/></th>
                            <!-- 创建日期 -->
                            <th><spring:message code="user_creatDate"/></th>
                        </tr>
                    </thead>
                     <c:if test="${not empty page.list}" >
                        <tbody>
                            <c:forEach items="${page.list}" var="user" varStatus="status">
                                <tr>
                                    <td>
                                        <p>${(page.pageNo-1)*page.pageSize + status.index+1}</p>
                                    </td>
                                    <td>
                                        <shiro:hasPermission name="sys:user:view">
                                            <p class="show" onclick="popup('800px','470px','${ctx}/sys/user/show?id=${user.id}')">${user.loginName}</p>
                                        </shiro:hasPermission>
                                    </td>
                                    <td>
                                        <p>${user.firstName}</p>
                                    </td>
                                    <td>
                                        <p>${user.lastName}</p>
                                    </td>
                                     <td>
                                        <p>
                                            ${fns:getDictName(user.sex)}
                                        </p>
                                    </td>
                                    <td>
                                        <p>${user.role.roleName}</p>
                                    </td>
                                    <td>
                                        <p>
                                        <c:choose>
                                           <c:when test="${user.deleteFlag eq 0}"><spring:message code="common_normal"/></c:when>
                                           <c:when test="${user.deleteFlag eq 1}"><spring:message code="common_disable"/></c:when>
                                        </c:choose>
                                        </p>
                                    </td>
                                    <td>
                                        <p><fmt:formatDate value="${user.lastDate}" pattern="yyyy-MM-dd" /></p>
                                    </td>
                                    <td>
                                        <p>${user.userCreatUser}</p>
                                    </td>
                                    <td>
                                         <p><fmt:formatDate value="${user.createDate}" pattern="yyyy-MM-dd HH:mm" /></p>
                                    </td>
                                </tr>
                            </c:forEach>
                        </tbody>
                    </c:if>
                </table>
                <c:if test="${empty page.list}" >
                    <div class="tableNone">
                        <img src="${ctxStatic}/images/icon-03.png" height="20"> <spring:message code="There_is_no_data"/>
                    </div>
                </c:if>    
            </div>
            <%@ include file="/WEB-INF/views/include/page.jsp"%>
        </div>
        <script>
            var listH = $(':root').css('height');
            $(window.parent.$("#mainFrame").css('height',listH));
            window.onload = function(){
                var theadW = $('.tabScroll thead').width();
                var theadTh = $('.tabScroll thead tr th').length;
                $('.tabScroll thead tr th').width(theadW/theadTh);
                $('.tabScroll tbody tr:first-child td').each(function(){
                    var indexNum = $(this).index();
                    var tdWidth = $('.tabScroll tbody tr:first-child td').eq(indexNum).css('width');
                    $('.tabScroll thead tr th').eq(indexNum).width(tdWidth);
                });
           }
        </script>
    </body>
</html>